<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>守护云</title>
    <meta name="description" content="守护云">
    <meta name="keywords" content="守护云">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../js/imgUrl.js"></script>

    <style type="text/css">
        .el-main {
            position: absolute;
            top: 70px;
            bottom: 0px;
            left: 200px;
            right: 10px;
            padding: 0;
        }
    </style>
    <script src="../js/imgUrl.js"></script>
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div id="app" >
        <el-container>
            <el-header  class="main-header" style="height:70px;">
                <nav class="navbar navbar-static-top" :class=''>
                    <!-- Logo -->
                    <a href="#" class="logo" style="text-align:center">
                        <span class="logo-lg"><img src="../img/logo.png"></span>
                    </a>
                    <div class="right-menu">
                        <span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>
                        <el-dropdown class="avatar-container right-menu-item" trigger="click">
                            <div class="avatar-wrapper">
                                <img :src="img" class="user-avatar">
                            {{username}}
                        </div>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item divided>
                                <span style="display:block;" @click="xiugai()">修改密码</span>
                            </el-dropdown-item>
                            <el-dropdown-item divided>
                                <!--<span style="display:block;"><a href="/logout.do">退出</a></span>-->
                                <a href="/logout.do"><span style="display:block;">退出</span></a>
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </nav>
        </el-header>
        <el-container>
            <el-aside width="200px">
                <el-menu>
                    <!--一级菜单 循环-->
                    <el-submenu v-for="menu in menuList" :index="menu.path">
                        <template slot="title">
                            <i class="fa" :class="menu.icon"></i>
                            {{menu.title}}
                        </template>
                        <!-- 子菜单循环 -->
                        <template v-for="child in menu.children">
                            <el-menu-item :index="child.path">
                                <a :href="child.linkUrl" target="right">{{child.title}}</a>
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </el-menu>
            </el-aside>

            <el-container>
                    <iframe name="right" class="el-main" src="checkitem.html" width="90%" height="700px"
                        frameborder="0"></iframe>
            </el-container>
        </el-container>
    </el-container>

</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<!--异步请求-->
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el: '#app',

        data: {
            username: "", // 代表当前登录的对象名
            menuList: [],
            img: ""
        },
        created() {
            // 发送一个ajax请求  请求Controller获取当前登录用户的用户名 展示到页面中
            axios.get("/user/getUsername.do").then((res) => {
                if (res.data.flag) {
                    this.username = res.data.data.username;
                    this.img = imgUrl + res.data.data.img;
                }
            });

            // 发送一个ajax请求   请求动态菜单
            axios.get("/menu/dynamicMenu.do").then((res) => {
                if (res.data.flag) {
                    // 成功获取动态菜单
                    this.menuList = res.data.data;
                }
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '获取动态菜单失败'
                });
            })
        },
        methods: {
            xiugai() {
                location.href = "/pages/ChangePassword.html"
            }
        }
    });
</script>
</html>
